package com.fuxin.app.task;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @Author fuxin
 * @date 2019/2/27 10:04
 * @description
 */
public class MyTask implements Job {

	private long count = 0;
	@Autowired
	private RabbitTemplate rabbitTemplate;

	@Override
	public void execute(JobExecutionContext context) throws JobExecutionException {
		String msg = System.currentTimeMillis() + "\n执行次数：" + count++;
		System.out.println("quartz - 当前时间：" + msg);

		rabbitTemplate.convertAndSend("fx_spring_boot_mq", msg);
	}
}
